package cn.learn.service.impl;

import cn.learn.service.IMessageProvider;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.MessageChannel;

import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author huangyezhan
 * @version 1.0
 * @date 2020年12月22日0:45
 */
@EnableBinding(Source.class)//定义消息的推送管道
public class MessageProviderImpl implements IMessageProvider {

    /**
     * 消息发送管道
     */
    @Resource
    private MessageChannel output;

    @Override
    public boolean send() {
        String s = UUID.randomUUID().toString();
        System.out.println(s);
        return output.send(MessageBuilder.withPayload(s).build());
    }

}
